
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../views/layout/uIndex.vue'),
    redirect: '/order-statistics',
    children: [
      {
        path: '/order-statistics',
        component: () => import('@/views/index/statistics/uIndex'),
        meta: {
          title: '首页',
          icon: 'el-icon-menu'
        }
      },
      {
        path: '/system',
        component: () => import('@/views/layout/BrigeRouterView'),
        meta: {
          title: '系统设置',
          icon: 'el-icon-setting'
        },
        children: [
          {
            path: '/menu',
            component: () => import('@/views/system/menus/uIndex'),
            meta: {
              title: '菜单管理'
            },
          },
          {
            path: '/addMenus',
            component: () => import('@/views/system/menus/addMenus'),
            meta: {
              title: '菜单管理>添加菜单'
            },
          },
          {
            path: '/setMenus',
            component: () => import('@/views/system/menus/setMenus'),
            meta: {
              title: '菜单管理>修改菜单'
            },
          },
          {
            path: '/role',
            component: ()=>import('@/views/system/role/uIndex.vue'),
            meta: {
              title: '角色管理'
            },
          },
          {
            path: '/addRole',
            component: () => import('@/views/system/role/addRole.vue'),
            meta: {
              title: '角色管理>添加角色'
            },
          },
          {
            path: '/setRole',
            component: () => import('@/views/system/role/setRole.vue'),
            meta: {
              title: '角色管理>修改角色'
            },
          },
          {
            path: '/user',
            component: () => import('@/views/system/user/uIndex.vue'),
            meta: {
              title: '管理员管理'
            },
          },
          {
            path: '/addUser',
            component: () => import('@/views/system/user/addUser.vue'),
            meta: {
              title: '管理员管理>添加用户'
            },
          },
          {
            path: '/setUser',
            component: () => import('@/views/system/user/setUser.vue'),
            meta: {
              title: '管理员管理>修改用户'
            },
          },
        ]
      },
      {
        path: '/shop',
        component: () => import('@/views/layout/BrigeRouterView'),
        meta: {
          title: '商城管理',
        },
        children:[{
          path: '/category',
          component: () => import('@/views/shop/class/uIndex.vue'),
          meta: {
            title: '商品分类'
          },
        },
        {
          path: '/addCate',
          component: () => import('@/views/shop/class/addCate.vue'),
          meta: {
            title: '商品分类>分类添加'
          },
        },
        {
          path: '/setCate',
          component: () => import('@/views/shop/class/setCate.vue'),
          meta: {
            title: '商品分类>分类修改'
          },
        },
        {
          path: '/specs',
          component: () => import('@/views/shop/specification/uIndex.vue'),
          meta: {
            title: '规格列表'
          },
        },
        {
          path: '/add_specs',
          component: () => import('@/views/shop/specification/addSpecs.vue'),
          meta: {
            title: '规格列表>规格添加'
          },
        },
        {
          path: '/setSpecs',
          component: () => import('@/views/shop/specification/setSpecs.vue'),
          meta: {
            title: '规格列表>规格修改'
          },
        },
        {
          path: '/goods',
          component: () => import('@/views/shop/goods/uIndex.vue'),
          meta: {
            title: '商品管理'
          },
        },
        {
          path: '/addGoods',
          component: () => import('@/views/shop/goods/addGoods.vue'),
          meta: {
            title: '商品管理>添加商品'
          },
        },
        {
          path: '/member',
          component: () => import('@/views/shop/member/uIndex.vue'),
          meta: {
            title: '会员管理'
          },
        },
        {
          path: '/setMember',
          component: () => import('@/views/shop/member/setMember.vue'),
          meta: {
            title: '会员管理>会员编辑'
          },
        },
        {
          path: '/banner',
          component: () => import('@/views/shop/banner/uIndex.vue'),
          meta: {
            title: '活动管理'
          },
        },
        {
          path: '/addBanner',
          component: () => import('@/views/shop/banner/addBanner.vue'),
          meta: {
            title: '活动管理>添加轮播图'
          },
        },
        {
          path: '/setBanner',
          component: () => import('@/views/shop/banner/setBanner.vue'),
          meta: {
            title: '活动管理>修改轮播图'
          },
        },
        {
          path: '/orders',
          component: () => import('@/views/shop/orders/uIndex.vue'),
          meta: {
            title: '订单管理'
          },
        },
        {
          path: '/seckill',
          component: () => import('@/views/shop/seckill/uIndex.vue'),
          meta: {
            title: '秒杀活动'
          },
        },
        {
          path: '/addSeckill',
          component: () => import('@/views/shop/seckill/addSeckill.vue'),
          meta: {
            title: '秒杀活动>增加活动'
          },
        },
        {
          path: '/setSeckill',
          component: () => import('@/views/shop/seckill/setSeckill.vue'),
          meta: {
            title: '秒杀活动>修改活动'
          },
        },
      ]
      }
    ]
  },
  {
    path: '/userlogin',
    component: () => import('@/views/uLogin')
  },

]

const router = new VueRouter({
  routes
})

/* function goPath(flag,str,arr){
  for(var i=0;i<arr.length;i++){
    if(str==arr[i].url){
     flag=true
     console.log(flag,555555555555);
     break
    }
    if(arr[i].children){
      flag=goPath(flag,str,arr[i].children)
    }
  }
  return flag
} */

/* router.beforeEach((to,from,next)=>{
  let temp =JSON.parse(localStorage.getItem('permiss'))
  console.log(to.path,1111111);
  console.log(temp,2222);
  var flag=false
  flag=goPath(flag,to.path,temp)
  console.log(flag,3333);
  if(to.path=='/' || to.path=='/order-statistics'){
    next()
  }
}) */
export default router
